package per.sen.shopping.domain.entities;

import cn.hutool.crypto.digest.BCrypt;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import per.sen.shopping.infrastructure.utils.PasswordUtil;

/**
 * @Descibe: 领域实体:用户行为
 * @Author: LYS
 * @Date: 2024/5/30 17:18
 */
@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
@Data
public class SysBackendUserEntity {
    //----用户行为----:
    //用户账户状态控制
    private String username;
    private String password;
    private String userMobile;
    private String userEmail;
    private Integer userGender;
    private String accountStatus;
    //获取用户信息
    public static SysBackendUserEntity getUserInfo(String username,String password,String userMobile,Integer userGender){
        return SysBackendUserEntity.builder()
                .username(username)
                .password(password)
                .userMobile(userMobile)
                .userGender(userGender)
                .accountStatus("0")
                .build();
    }
    //用户密码加密
    public static  String enCodePassword(String password){
        return PasswordUtil.hashPassword(password);
    }
    //验证密码是否一致
    public static boolean matchesPassword(String password,String hashedPassword){
        return BCrypt.checkpw(password,hashedPassword);
    }



}
